#include "TaskQueue.h"

void TaskQueue::push(Channel* channel)
{
  std::unique_lock<std::mutex> lock(m_mutex);
  m_queue.push(channel);
  m_cv.notify_one();
}

Channel* TaskQueue::pop()
{
  std::unique_lock<std::mutex> lock(m_mutex);
  m_cv.wait(lock, [this] { return !m_queue.empty(); });
  Channel* channel = m_queue.front();
  m_queue.pop();
  return channel;
}

bool TaskQueue::empty() const
{
  std::unique_lock<std::mutex> lock(m_mutex);
  return m_queue.empty();
}